<?php
include_once("commonMysql.class.php");
class Goods extends commonMysql{

    /**
     * 获取商品的信息
     * @param $where
     */
    public function getRowGoodsInfo($where=array()){
        $sqlWhere=" WHERE 1=1";

        if($where!=""){
            foreach ($where as $k =>$v){
                $sqlWhere.=" AND ".$k."='".$v."' ";
            }
        }
        $sql="select * from goods  $sqlWhere";
        $rs=mysqli_query($this->conn,$sql);
        $row=mysqli_fetch_assoc($rs);


        return $row;
    }

    /**
     * 库存减少
     */
    public function updateCount($gooodsInfo){
        $sql="UPDATE goods SET  counts= counts-1 WHERE goodsId = {$gooodsInfo['goodsId']} ";
        $rs=mysqli_query($this->conn,$sql);
        return $rs;
    }

}